ソースを参照

1.针对群聊搜不到小程序、无法选中小程序,优化rpa操作流程
2.针对解散群聊的rpa操作流程优化
3.朋友圈rpa任务下发完成发表

yangyang 7 ヶ月 前
コミット
40ba52ddac

+ 2 - 2
app/build.gradle

@@ -9,8 +9,8 @@ android {
         applicationId "com.rk.worktool"
         minSdkVersion 24
         targetSdkVersion 30
-        versionCode 20250528
-        versionName "2.9.6"
+        versionCode 20250617
+        versionName "2.9.7"
     }
 
     buildTypes {

+ 3 - 0
app/src/main/java/org/yameida/worktool/model/ExecCallbackBean.kt

@@ -25,6 +25,9 @@ data class ExecCallbackBean(
     //失败名单
     var failList: List<String>? = null,
 
+    //失败名单
+    var disbandList: List<String>? = null,
+
     //附加信息
     var metaJson: String? = null
 

+ 2 - 0
app/src/main/java/org/yameida/worktool/model/WeworkMessageBean.java

@@ -106,6 +106,8 @@ public class WeworkMessageBean {
 
     public static final int SEND_GROUP_CHAT = 235;
 
+    public static final int PUBLISH_MOMENTS = 236;
+
     public static final int ROBOT_LOG = 301;
     public static final int ROBOT_ERROR_LOG = 302;
     public static final int ROBOT_CONTROLLER_TEST = 303;

+ 2 - 0
app/src/main/java/org/yameida/worktool/model/operation/SelectResult.kt

@@ -6,6 +6,8 @@ class SelectResult {
 
     var failList = arrayListOf<String>()
 
+    var disbandList = arrayListOf<String>()
+
     var result = false
 
 }

+ 58 - 0
app/src/main/java/org/yameida/worktool/service/GlobalMethod.kt

@@ -344,6 +344,7 @@ fun uploadCommandResult(
             (System.currentTimeMillis() - startTime) / 1000.0,
             successList,
             failList,
+            null,
             metaJson
         )
     )
@@ -357,6 +358,63 @@ fun uploadCommandResult(
                 (System.currentTimeMillis() - startTime) / 1000.0,
                 successList,
                 failList,
+                null,
+                metaJson
+            ),
+            WeworkMessageListBean.SOCKET_TYPE_RAW_CONFIRM,
+            messageId = message.messageId,
+            action = message.action,
+            meta = message.meta
+        ), true
+    )
+    if (errorCode != 0) {
+        if (message.apiSend == 1) {
+            ToastUtils.show("错误提示 错误码: $errorCode 错误信息: $errorReason")
+        }
+        LogUtils.v("错误提示 错误码: $errorCode 错误信息: $errorReason")
+    }
+}
+
+/**
+ * 上传执行指令结果
+ */
+fun uploadCommandResult(
+    message: WeworkMessageBean,
+    errorCode: Int,
+    errorReason: String,
+    startTime: Long,
+    successList: List<String> = listOf(),
+    failList: List<String> = listOf(),
+    disbandList:List<String> = listOf(),
+    metaJson: String? = null
+) {
+    if ((message.fileBase64?.length ?: 0) > 100) {
+        message.fileBase64 = message.fileBase64.substring(0, 100)
+    }
+    completeMap[message.messageId] = GsonUtils.toJson(
+        ExecCallbackBean(
+            GsonUtils.toJson(message),
+            errorCode,
+            errorReason,
+            startTime,
+            (System.currentTimeMillis() - startTime) / 1000.0,
+            successList,
+            failList,
+            disbandList,
+            metaJson
+        )
+    )
+    WeworkController.weworkService.webSocketManager.send(
+        WeworkMessageListBean(
+            ExecCallbackBean(
+                GsonUtils.toJson(message),
+                errorCode,
+                errorReason,
+                startTime,
+                (System.currentTimeMillis() - startTime) / 1000.0,
+                successList,
+                disbandList,
+                failList,
                 metaJson
             ),
             WeworkMessageListBean.SOCKET_TYPE_RAW_CONFIRM,

+ 4 - 0
app/src/main/java/org/yameida/worktool/service/MyLooper.kt

@@ -389,6 +389,10 @@ object MyLooper {
             WeworkMessageBean.SEND_GROUP_CHAT -> {
                 WeworkController.sendGroupChat(message)
             }
+
+            WeworkMessageBean.PUBLISH_MOMENTS -> {
+                WeworkController.publishMoments(message)
+            }
         }
     }
 }

+ 9 - 0
app/src/main/java/org/yameida/worktool/service/WeworkController.kt

@@ -771,4 +771,13 @@ object WeworkController {
     fun sendGroupChat(message: WeworkMessageBean):Boolean{
         return WeworkOperationImpl.sendGroupChat(message)
     }
+
+    /**
+     * 朋友圈发表
+     * @see WeworkMessageBean.GET_CORP_LIST
+     */
+    @RequestMapping
+    fun publishMoments(message: WeworkMessageBean):Boolean{
+        return WeworkOperationImpl.publishMoments(message)
+    }
 }

+ 0 - 8
app/src/main/java/org/yameida/worktool/service/WeworkLoopImpl.kt

@@ -113,14 +113,6 @@ object WeworkLoopImpl {
             if (childCount == 4 || childCount == 5) {
                 if (item.parent != null && item.parent.childCount > 1) {
                     LogUtils.d("通讯录有红点")
-//                    WeworkController.weworkService.webSocketManager.send(
-//                        WeworkMessageBean(
-//                            WeworkMessageBean.ADD_FRIEND,
-//                            SPUtils.getInstance().getInt("weCom"),
-//                            1,
-//                            null
-//                        )
-//                    )
                     AccessibilityUtil.performClick(item)
                     val hasRecommendFriend = AccessibilityUtil.findOneByText(
                         getRoot(),

+ 99 - 22
app/src/main/java/org/yameida/worktool/service/WeworkOperationImpl.kt

@@ -278,7 +278,8 @@ object WeworkOperationImpl {
                                 "$title: 转发成功",
                                 startTime,
                                 relaySelectResult.successList,
-                                relaySelectResult.failList
+                                relaySelectResult.failList,
+                                relaySelectResult.disbandList
                             )
                             goHome()
                             return true
@@ -333,7 +334,8 @@ object WeworkOperationImpl {
                                 "$title: 转发成功",
                                 startTime,
                                 relaySelectResult.successList,
-                                relaySelectResult.failList
+                                relaySelectResult.failList,
+                                relaySelectResult.disbandList
                             )
                             goHome()
                             return true
@@ -688,8 +690,12 @@ object WeworkOperationImpl {
                 fastIn = false
             )) && WeworkRoomUtil.intoGroupManager()
         ) {
-            val groupManagerTv =
-                AccessibilityUtil.findOneByText(getRoot(), "群管理", exact = true, timeout = 2000)
+            val groupManagerTv = AccessibilityUtil.scrollAndFindByText(
+                WeworkController.weworkService,
+                getRoot(),
+                "群管理",
+                exact = true
+            )
             if (groupManagerTv != null) {
                 AccessibilityUtil.performClick(groupManagerTv)
                 val dismissTv =
@@ -913,7 +919,8 @@ object WeworkOperationImpl {
                             "",
                             startTime,
                             relaySelectResult.successList,
-                            relaySelectResult.failList
+                            relaySelectResult.failList,
+                            relaySelectResult.disbandList
                         )
                         goHome()
                         return true
@@ -1047,7 +1054,8 @@ object WeworkOperationImpl {
                             "",
                             startTime,
                             relaySelectResult.successList,
-                            relaySelectResult.failList
+                            relaySelectResult.failList,
+                            relaySelectResult.disbandList
                         )
                         goHome()
                         return true
@@ -1130,7 +1138,8 @@ object WeworkOperationImpl {
                     "",
                     startTime,
                     relaySelectResult.successList,
-                    relaySelectResult.failList
+                    relaySelectResult.failList,
+                    relaySelectResult.disbandList
                 )
                 goHome()
                 return true
@@ -1239,7 +1248,8 @@ object WeworkOperationImpl {
                     "",
                     startTime,
                     relaySelectResult.successList,
-                    relaySelectResult.failList
+                    relaySelectResult.failList,
+                    relaySelectResult.disbandList
                 )
                 goHome()
                 return true
@@ -1346,7 +1356,8 @@ object WeworkOperationImpl {
                         "",
                         startTime,
                         relaySelectResult.successList,
-                        relaySelectResult.failList
+                        relaySelectResult.failList,
+                        relaySelectResult.disbandList
                     )
                     goHome()
                     return true
@@ -1545,7 +1556,8 @@ object WeworkOperationImpl {
                             "",
                             startTime,
                             relaySelectResult.successList,
-                            relaySelectResult.failList
+                            relaySelectResult.failList,
+                            relaySelectResult.disbandList
                         )
                         goHome()
                         return true
@@ -1737,7 +1749,8 @@ object WeworkOperationImpl {
                         "",
                         startTime,
                         relaySelectResult.successList,
-                        relaySelectResult.failList
+                        relaySelectResult.failList,
+                        relaySelectResult.disbandList
                     )
                     goHome()
                     return true
@@ -1866,7 +1879,8 @@ object WeworkOperationImpl {
                     "",
                     startTime,
                     relaySelectResult.successList,
-                    relaySelectResult.failList
+                    relaySelectResult.failList,
+                    relaySelectResult.disbandList
                 )
                 if (message.isRelay) {
                     message.weCom = 2
@@ -2377,7 +2391,8 @@ object WeworkOperationImpl {
                             "$groupName: 转发成功",
                             startTime,
                             relaySelectResult.successList,
-                            relaySelectResult.failList
+                            relaySelectResult.failList,
+                            relaySelectResult.disbandList
                         )
                         goHome()
                         return true
@@ -2562,6 +2577,7 @@ object WeworkOperationImpl {
                             } else {
                                 LogUtils.e("$title: 多选失败")
                                 if (retryCount > 0) {
+                                    goHome()
                                     return relayMultiMessage(
                                         message,
                                         titleList,
@@ -2596,6 +2612,7 @@ object WeworkOperationImpl {
                             } else {
                                 LogUtils.e("$title: 多选失败")
                                 if (retryCount > 0) {
+                                    goHome()
                                     return relayMultiMessage(
                                         message,
                                         titleList,
@@ -2618,7 +2635,7 @@ object WeworkOperationImpl {
                             }
                         }
                     } else {
-                         AccessibilityUtil.scrollAndFindByText(
+                        AccessibilityUtil.scrollAndFindByText(
                             WeworkController.weworkService,
                             getRoot(),
                             originalContent,
@@ -2683,7 +2700,8 @@ object WeworkOperationImpl {
                                     "$title: 转发成功",
                                     startTime,
                                     relaySelectResult.successList,
-                                    relaySelectResult.failList
+                                    relaySelectResult.failList,
+                                    relaySelectResult.disbandList
                                 )
                                 goHome()
                                 return true
@@ -3476,7 +3494,8 @@ object WeworkOperationImpl {
                                     "",
                                     startTime,
                                     relaySelectResult.successList,
-                                    relaySelectResult.failList
+                                    relaySelectResult.failList,
+                                    relaySelectResult.disbandList
                                 )
                                 goHome()
                                 return true
@@ -4093,6 +4112,7 @@ object WeworkOperationImpl {
                         timeout = Constant.CHANGE_PAGE_INTERVAL * 3,
                         root = false
                     )
+                    var isDisband = false
                     if (selectListView != null && matchSelect != null) {
                         for (i in 0 until selectListView.childCount) {
                             val item = selectListView.getChild(i)
@@ -4106,12 +4126,24 @@ object WeworkOperationImpl {
                                     root = false
                                 )
                                 AccessibilityUtil.performClick(imageView)
+                                sleep(Constant.POP_WINDOW_INTERVAL)
+                                //双重校验
+                                val remove =
+                                    AccessibilityUtil.findOneByText(getRoot(), "你已被移出了群聊")
                                 isSelect = true
+                                if (remove != null) {
+                                    isDisband = true
+                                    val confirm = AccessibilityUtil.findOneByText(getRoot(), "确定")
+                                    AccessibilityUtil.performClick(confirm)
+                                }
                                 break
                             }
                         }
                     }
-                    if (matchSelect != null) {
+                    if (isDisband) {
+                        selectResult.disbandList.add(select)
+                        LogUtils.d("找到搜索结果已经解散: $select")
+                    } else if (matchSelect != null) {
                         selectResult.successList.add(select)
                         LogUtils.d("找到搜索结果: $select")
                     } else {
@@ -4194,11 +4226,7 @@ object WeworkOperationImpl {
                     "企业微信"
                 )
                 if (aList.size == 2) {
-//                if (1 == SPUtils.getInstance().getInt("weCom")) {
                     AccessibilityUtil.performClick(aList.firstOrNull())
-//                } else {
-//                    AccessibilityUtil.performClick(aList.lastOrNull())
-//                }
                 }
                 sleep(Constant.BASE_CHANGE_PAGE_INTERVAL)
             }
@@ -4252,6 +4280,7 @@ object WeworkOperationImpl {
                     timeout = Constant.CHANGE_PAGE_INTERVAL * 3,
                     root = false
                 )
+                var isDisband = false
                 if (selectListView != null && matchSelect != null) {
                     for (i in 0 until selectListView.childCount) {
                         val item = selectListView.getChild(i)
@@ -4265,12 +4294,24 @@ object WeworkOperationImpl {
                                 root = false
                             )
                             AccessibilityUtil.performClick(imageView)
+                            sleep(Constant.POP_WINDOW_INTERVAL)
+                            //双重校验
+                            val remove =
+                                AccessibilityUtil.findOneByText(getRoot(), "你已被移出了群聊")
                             isSelect = true
+                            if (remove != null) {
+                                isDisband = true
+                                val confirm = AccessibilityUtil.findOneByText(getRoot(), "确定")
+                                AccessibilityUtil.performClick(confirm)
+                            }
                             break
                         }
                     }
                 }
-                if (matchSelect != null) {
+                if (isDisband) {
+                    selectResult.disbandList.add(select)
+                    LogUtils.d("找到搜索结果已经解散: $select")
+                } else if (matchSelect != null) {
                     selectResult.successList.add(select)
                     LogUtils.d("找到搜索结果: $select")
                 } else {
@@ -6972,4 +7013,40 @@ object WeworkOperationImpl {
         return true
     }
 
+    fun publishMoments(message: WeworkMessageBean): Boolean {
+        if (WeworkRoomUtil.intoGroupChat("客户朋友圈") || WeworkRoomUtil.intoGroupChat(
+                "客户朋友圈",
+                fastIn = false
+            )||WeworkRoomUtil.intoGroupChat("学员朋友圈") || WeworkRoomUtil.intoGroupChat(
+                "学员朋友圈",
+                fastIn = false
+            )
+        ) {
+            val tvGoPublish = AccessibilityUtil.findOneByText(getRoot(), "去发表", exact = true)
+            if (tvGoPublish != null) {
+                AccessibilityUtil.performClick(tvGoPublish)
+                AccessibilityExtraUtil.loadingPage("MomentsEnterpriseNotificationListActivity")
+                val tvPublishList = AccessibilityUtil.findAllByText(getRoot(), "发表", exact = true)
+                LogUtils.d("发现${tvPublishList.size}条待发送")
+                for (tvPublish in tvPublishList) {
+                    AccessibilityUtil.performClick(tvPublish)
+                }
+                uploadCommandResult(
+                    message,
+                    ExecCallbackBean.SUCCESS,
+                    "",
+                    System.currentTimeMillis()
+                )
+                return true
+            }
+        }
+        uploadCommandResult(
+            message,
+            ExecCallbackBean.ERROR_TARGET,
+            "",
+            System.currentTimeMillis()
+        )
+        return false
+    }
+
 }