|
@@ -120,7 +120,7 @@ public class AWImplClient implements AWClint {
|
|
|
}
|
|
|
}
|
|
|
// ppExt: TB有卡控, 校验交付物不能为空, 同时兼容非交付件任务类型
|
|
|
- List<Map> docs = _getDocs(taskData);
|
|
|
+ List<Map> docs = _getDocs(taskData, AWServer.TASK_APPROVE_ATTACHMENT);
|
|
|
McException.assertAccessException(!isCallback && docs.size() == 0, "任务交付件不能为空, 请填写后再操作!");
|
|
|
String executorId = UtilMap.getString(rTask, "executorId");
|
|
|
if (!isCallback) {
|
|
@@ -159,8 +159,8 @@ public class AWImplClient implements AWClint {
|
|
|
result = "未配置交付物审批";
|
|
|
}
|
|
|
}
|
|
|
- /// 发起评审
|
|
|
- if (StringUtils.isBlank(result)) {
|
|
|
+ /// 发起评审 prd 630 若无交付物审批, 则配置发起人自动通过, 以兼容全部任务类型可提交交付件评审
|
|
|
+ if (StringUtils.isBlank(result) || "未配置交付物审批".equals(result)) {
|
|
|
List<Map> roles = (List<Map>) rProject.get("tableField_lqxtykcf");
|
|
|
Map formData = UtilMap.map("selectField_lqxuswzd, textField_lrncs2fu", tCode, pCode);
|
|
|
formData.put("attachmentField_lqxtebtq", docs);
|
|
@@ -172,6 +172,7 @@ public class AWImplClient implements AWClint {
|
|
|
formData.put("textareaField_lw0nmvko", UtilMap.getString(taskData, AWServer.TASK_APPROVE_DESC)); // 交付件描述
|
|
|
formData.put("textField_lvbrueqs", UtilMap.getString(taskData, AWServer.TASK_PRODUCT)); // 产品型号
|
|
|
formData.put("textField_lvbrueqt", UtilMap.getString(taskData, AWServer.TASK_PRODUCT_VERSION)); // 产品版本
|
|
|
+ formData.put("radioField_ly2o9rxn", "未配置交付物审批".equals(result) ? "是" : "否"); // 审批分支
|
|
|
// 匹配任务编码与项目角色
|
|
|
List<Map<String, String>> compIds = Arrays.asList( // 任务表角色, 交付物评审表: 角色, 审批人
|
|
|
UtilMap.map("tsRole, prRole, prEmp", "multiSelectField_lrokzlo7, multiSelectField_lrokzlo7, employeeField_lqxtebtw"),
|
|
@@ -343,12 +344,12 @@ public class AWImplClient implements AWClint {
|
|
|
* 1. 宜搭附件传递 downloadUrl 和 name 即可实现在线预览
|
|
|
* 2. 知识库绑定没有文件后缀, 宜搭识别目前仅能点击下载跳转预览, 添加统一docx后缀, 文档会自行区分
|
|
|
* -
|
|
|
- * ppExt: 获取任务字段需要传递 AWServer.TASK_APPROVE_ATTACHMENT 以获取ID, 另外添加 .doc 只是重定向若是文件夹也不影响访问
|
|
|
+ * ppExt: 获取任务字段需要传递字段名称以获取ID, 另外添加 .doc 只是重定向若是文件夹也不影响访问
|
|
|
*/
|
|
|
- List<Map> _getDocs(Map taskData) {
|
|
|
+ List<Map> _getDocs(Map taskData, String fieldName) {
|
|
|
Map rTask = UtilMap.getMap(taskData, "task");
|
|
|
List<Map> customfields = UtilMap.getList(rTask, "customfields");
|
|
|
- String deliverable = String.valueOf(taskData.get(AWServer.TASK_APPROVE_ATTACHMENT + "_id")); // 交付物任务字段ID
|
|
|
+ String deliverable = String.valueOf(taskData.get(fieldName + "_id")); // 交付物任务字段ID
|
|
|
List<Map> attachments = TBConf.getTaskFieldValue(customfields, deliverable).stream().map(item -> {
|
|
|
Map link = (Map) JSON.parse(String.valueOf(item.get("metaString")));
|
|
|
Map row = UtilMap.map("downloadUrl, name", link.get("url"), link.get("title") + ".docx");
|
|
@@ -1284,6 +1285,8 @@ public class AWImplClient implements AWClint {
|
|
|
String result = "";
|
|
|
String formInstanceId = "";
|
|
|
List<String> staffIds = new ArrayList<>();
|
|
|
+ List<Map> subList = null;
|
|
|
+
|
|
|
// 通用账户unionId
|
|
|
String unionId = String.valueOf(ddClient_contacts.getUserInfoById(ddClient.getAccessToken(), ddConf.getOperator()).get("unionid"));
|
|
|
// 知识库 & 项目信息处理
|
|
@@ -1302,6 +1305,7 @@ public class AWImplClient implements AWClint {
|
|
|
staffIds.addAll((List) detail.get("employeeField_lqxtykch_id"));
|
|
|
}
|
|
|
}
|
|
|
+ subList = details; // 子表数据
|
|
|
if (StringUtils.isBlank(workspaceId)) {
|
|
|
// 获取知识库空间Id [ ppExt: 知识库列表接口, 查询受到 operatorId 权限控制, 仅会返回操作者有权限知识库 ] todo tb提供接口返回知识库相关信息
|
|
|
List<Map> workspaces = ddClient_storage.searchWorkspaces(ddClient.getAccessToken(), unionId, pCode, null);
|
|
@@ -1333,7 +1337,7 @@ public class AWImplClient implements AWClint {
|
|
|
log.error(e.getMessage(), e);
|
|
|
}
|
|
|
// 知识库文件夹 & 拷贝处理 [prd 文件目录结构 TR评审节点/资源名称]
|
|
|
- Map taskData = _getTaskFieldMap(taskId, AWServer.TASK_APPROVE_ATTACHMENT, AWServer.TASK_STAGE, AWServer.TASK_ROLE);
|
|
|
+ Map taskData = _getTaskFieldMap(taskId, AWServer.TASK_APPROVE_ATTACHMENT, AWServer.TASK_APPROVE_VERSION, AWServer.TASK_STAGE, AWServer.TASK_ROLE);
|
|
|
Map rTask = UtilMap.getMap(taskData, "task");
|
|
|
// fixme: 知识库所有操作和权限都与依赖于权限, 通过 spaceId + dentryId 查询创建人需要传递操作者, 操作者需要有查看以上权限. todo 目前临时读取执行人, tb文档相关信息需要返回创建人信息
|
|
|
Map<String, String> extra = (Map) tbClient.idMapQuery(UtilMap.getString(rTask, "executorId"), "dingTalk-user", ddConf.getCorpId()).get(0).get("extra");
|
|
@@ -1363,7 +1367,7 @@ public class AWImplClient implements AWClint {
|
|
|
fileName = fileName + "/" + tName;
|
|
|
record = _upsertFileAbsolutePath("文件夹", fileName, pCode, UtilMap.getString(rTask, "projectId"), workspaceId, rootNodeId, unionId);
|
|
|
rootNodeId = UtilMap.getString(record, "rootNodeId"); // 最新文件路径下ID
|
|
|
- List<Map> docs = _getDocs(taskData);
|
|
|
+ List<Map> docs = _getDocs(taskData, AWServer.TASK_APPROVE_ATTACHMENT);
|
|
|
log.info("docs, {}", docs);
|
|
|
List<Map> attas = new ArrayList<>();
|
|
|
for (Map doc : docs) {
|
|
@@ -1389,6 +1393,7 @@ public class AWImplClient implements AWClint {
|
|
|
DDR_New ddr_new;
|
|
|
try {
|
|
|
ddr_new = ddClient_storage.copyDentries(ddClient.getAccessToken(), unionId, workspaceId, UtilMap.getString(doc, "instanceId"), workspaceId, rootNodeId, docName);
|
|
|
+ _updatePermission(ddr_new.getDentryUuid(), unionId, tName, subList); // 设置文件权限矩阵
|
|
|
} catch (McException e) {
|
|
|
// ppExt: 权限异常可能原因是重复授权, 依然执行复制操作, 再跳过
|
|
|
log.error(e.getMessage(), e);
|
|
@@ -1410,6 +1415,17 @@ public class AWImplClient implements AWClint {
|
|
|
if (attas.isEmpty()) {
|
|
|
result = "无编辑权限, 复制失败";
|
|
|
} else {
|
|
|
+ // prd 630 多文件传递时, 可能会删除其中交付件, 交付件版本保留全量的记录
|
|
|
+ for (Map doc : _getDocs(taskData, AWServer.TASK_APPROVE_VERSION)) {
|
|
|
+ Optional optional = attas.stream().filter(item -> {
|
|
|
+ String curName = UtilMap.getString(doc, "title").split(" v")[0];
|
|
|
+ String preName = UtilMap.getString(item, "title").split(" v")[0];
|
|
|
+ return curName.equals(preName);
|
|
|
+ }).findAny();
|
|
|
+ if (!optional.isPresent()) {
|
|
|
+ attas.add(UtilMap.map("title, metaString", UtilMap.getString(doc, "title"), JSON.toJSONString(doc)));
|
|
|
+ }
|
|
|
+ }
|
|
|
// 多文件更新回写 [ fixme: 更新任务自定义字段值 ]
|
|
|
tbClient.updateTaskCustomField(taskId, tbConf.getOperatorId(), UtilMap.map("customfieldName, value", AWServer.TASK_APPROVE_VERSION, attas));
|
|
|
}
|
|
@@ -1422,9 +1438,52 @@ public class AWImplClient implements AWClint {
|
|
|
log.info("知识库版本管理, {}", result);
|
|
|
}
|
|
|
|
|
|
+ /// 交付件权限设置,包括TBManager账号设置为只读,针对文件. 移除非权限矩阵的项目成员
|
|
|
+ private void _updatePermission(String dentryUuid, String creatorUnionId, String roleName, List<Map> details) {
|
|
|
+
|
|
|
+ ddClient_storage.updateDentryPermissionsInheritances(ddClient.getAccessToken(), dentryUuid, creatorUnionId, "BREAK");
|
|
|
+ List<String> staffIds = new ArrayList<>();
|
|
|
+ try { // todo 目前权限绑定群聊会异常, BUG
|
|
|
+ List<Map> allMembers = ddClient_storage.queryDentryPermissions(ddClient.getAccessToken(), dentryUuid, creatorUnionId, null);
|
|
|
+ for (Map member : allMembers) {
|
|
|
+ Map<String, String> team = UtilMap.getMap(member, "member");
|
|
|
+ if ("USER".equals(UtilMap.getString(team, "type"))) {
|
|
|
+ String roleId = UtilMap.getString(UtilMap.getMap(member, "role"), "id");
|
|
|
+ String userId = UtilMap.getString(team, "id");
|
|
|
+ if (!Arrays.asList("OWNER", "MANAGER").contains(roleId)) {
|
|
|
+ staffIds.add(userId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // ppExt: 不移除 TBManager 权限, 避免不可见
|
|
|
+ if (staffIds.contains(ddConf.getOperator())) {
|
|
|
+ staffIds.remove(ddConf.getOperator());
|
|
|
+ }
|
|
|
+ log.info("删除文件权限 {}, {}, {}", dentryUuid, staffIds);
|
|
|
+
|
|
|
+ // 权限成员列表,最大size30, 通过 partition 快速切割[ 只读权限]
|
|
|
+ List<List<String>> parts = Lists.partition(staffIds, DDConf.WORKSPACE_PERMISSION_SIZE);
|
|
|
+ for (List<String> ids : parts) {
|
|
|
+ List<Map> members = ids.stream().map(userId -> UtilMap.map("type, id", "USER", userId)).collect(Collectors.toList());
|
|
|
+ // ppExt 会自动移除更低的权限
|
|
|
+ ddClient_storage.deleteDentryPermissions(ddClient.getAccessToken(), dentryUuid, creatorUnionId, "EDITOR", members, null);
|
|
|
+ }
|
|
|
+ } catch (McException e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取角色在项目主数据对应成员 [ todo 取值权限矩阵 ]
|
|
|
+ Optional optional = details.stream().filter(item -> roleName.equals(item.get("selectField_lqxu6bgf"))).findAny();
|
|
|
+ if (!optional.isPresent()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<String> roleIds = (List<String>) UtilMap.getList((Map) optional.get(), "employeeField_lqxtykch_id");
|
|
|
+ List<Map> members = roleIds.stream().map(userId -> UtilMap.map("type, id", "USER", userId)).collect(Collectors.toList());
|
|
|
+ ddClient_storage.updateDentryPermissions(ddClient.getAccessToken(), dentryUuid, creatorUnionId, "READER", members, null);
|
|
|
+ }
|
|
|
+
|
|
|
/// 更新一级归档目录 dentryUuid 权限打断, 并更新项目成员只读权限, 且更新记录实例ID [ 用于后续项目全量同步时, 刷新权限 ]
|
|
|
- private void _breakPermission(String rootNodeId, String dentryUuid, List<String> staffIds, String
|
|
|
- creatorUnionId, String formInstanceId) {
|
|
|
+ private void _breakPermission(String rootNodeId, String dentryUuid, List<String> staffIds, String creatorUnionId, String formInstanceId) {
|
|
|
|
|
|
ddClient_storage.updateDentryPermissionsInheritances(ddClient.getAccessToken(), dentryUuid, creatorUnionId, "BREAK");
|
|
|
try { // todo 目前权限绑定群聊会异常, BUG
|
|
@@ -1489,14 +1548,14 @@ public class AWImplClient implements AWClint {
|
|
|
|
|
|
@Override
|
|
|
public void test() {
|
|
|
-// approveVersion("659a681d44ade3345fdc0d39", "99999");
|
|
|
+ approveVersion("659a681d44ade3345fdc0d39", "99999");
|
|
|
|
|
|
String pCode = "99999";
|
|
|
// String pCode = "A240407DryRun";
|
|
|
//
|
|
|
- List<Map> pList = ydService.queryDataList_FormData(_matchFormUuid("PROJECT"), UtilMap.map("textField_lrj7vnxb", pCode));
|
|
|
- pList = pList.stream().filter(item -> pCode.equals(item.get("textField_lrj7vnxb"))).collect(Collectors.toList());
|
|
|
- _assembleBreakPermission(pList.get(0));
|
|
|
+// List<Map> pList = ydService.queryDataList_FormData(_matchFormUuid("PROJECT"), UtilMap.map("textField_lrj7vnxb", pCode));
|
|
|
+// pList = pList.stream().filter(item -> pCode.equals(item.get("textField_lrj7vnxb"))).collect(Collectors.toList());
|
|
|
+// _assembleBreakPermission(pList.get(0));
|
|
|
|
|
|
// String creatorUnionId = String.valueOf(ddClient_contacts.getUserInfoById(ddClient.getAccessToken(), "095358016629044412").get("unionid"));
|
|
|
// List<Map> allMembers = ddClient_storage.queryDentryPermissions(ddClient.getAccessToken(), "14lgGw3P8vMDNPvMC7aw11LzJ5daZ90D", creatorUnionId, null);
|