浏览代码

修改任务为异步执行

xuzuoyun 5 年之前
父节点
当前提交
d9b2e01198

+ 1 - 1
module-crawler/src/main/java/cn/com/ctop/crawler/modules/appium/entity/AppiumDevice.java

@@ -31,7 +31,7 @@ public class AppiumDevice {
     /**
      * 主键
      */
-    @TableId(type = IdType.INPUT)
+    @TableId(type = IdType.AUTO)
     @ApiModelProperty(value = "主键")
     private Integer id;
     /**

+ 1 - 1
module-crawler/src/main/java/cn/com/ctop/crawler/modules/appium/entity/AppiumTask.java

@@ -33,7 +33,7 @@ public class AppiumTask {
     /**
      * 主键
      */
-    @TableId(type = IdType.INPUT)
+    @TableId(type = IdType.AUTO)
     @ApiModelProperty(value = "主键")
     private Integer id;
     /**

+ 1 - 1
module-crawler/src/main/java/cn/com/ctop/crawler/modules/appium/entity/AppiumTaskItem.java

@@ -33,7 +33,7 @@ public class AppiumTaskItem {
 	/**
 	 * 主键
 	 */
-	@TableId(type = IdType.INPUT)
+	@TableId(type = IdType.AUTO)
 	@ApiModelProperty(value = "主键")
 	private Integer id;
 	/**

+ 1 - 1
module-crawler/src/main/java/cn/com/ctop/crawler/modules/appium/entity/AppiumTaskLog.java

@@ -33,7 +33,7 @@ public class AppiumTaskLog {
     /**
      * 主键
      */
-    @TableId(type = IdType.UUID)
+    @TableId(type = IdType.AUTO)
     @ApiModelProperty(value = "主键")
     private Integer id;
     /**

+ 7 - 4
module-crawler/src/main/java/cn/com/ctop/crawler/modules/appium/service/impl/AppiumTaskServiceImpl.java

@@ -5,6 +5,7 @@ import cn.com.ctop.crawler.modules.appium.entity.AppiumTask;
 import cn.com.ctop.crawler.modules.appium.entity.AppiumTaskItem;
 import cn.com.ctop.crawler.modules.appium.entity.AppiumTaskLog;
 import cn.com.ctop.crawler.modules.appium.mapper.AppiumTaskItemMapper;
+import cn.com.ctop.crawler.modules.appium.mapper.AppiumTaskLogMapper;
 import cn.com.ctop.crawler.modules.appium.mapper.AppiumTaskMapper;
 import cn.com.ctop.crawler.modules.appium.service.IAppiumDeviceService;
 import cn.com.ctop.crawler.modules.appium.service.IAppiumTaskItemService;
@@ -35,7 +36,7 @@ public class AppiumTaskServiceImpl extends ServiceImpl<AppiumTaskMapper, AppiumT
     @Autowired
     private IAppiumDeviceService iAppiumDeviceService;
     @Autowired
-    private IAppiumTaskLogService iAppiumTaskLogService;
+    private AppiumTaskLogMapper appiumTaskLogMapper;
 
     public void runTask(Integer taskId, Integer deviceId) {
         AppiumTask task = this.getById(taskId);
@@ -44,11 +45,13 @@ public class AppiumTaskServiceImpl extends ServiceImpl<AppiumTaskMapper, AppiumT
         iAppiumDeviceService.updateById(appiumDevice);
         AppiumTaskLog log = new AppiumTaskLog();
         log.setDeviceId(deviceId);
+        log.setDeviceIp(appiumDevice.getIp());
         log.setDevicePort(appiumDevice.getPort());
         log.setStatus(1);
         log.setTaskId(taskId);
         log.setTaskName(task.getTaskName());
-        iAppiumTaskLogService.save(log);
+        appiumTaskLogMapper.insert(log);
+        log.setId(log.getId());
         List<AppiumTaskItem> taskItemList = iAppiumTaskItemService.initTaskItemList(taskId, null);
         AppiumUtil appiumUtil = new AppiumUtil();
         try {
@@ -58,14 +61,14 @@ public class AppiumTaskServiceImpl extends ServiceImpl<AppiumTaskMapper, AppiumT
                     appiumUtil.runTask(androidDriver, appiumTaskItem, null);
                 }
                 log.setStatus(2);
-                iAppiumTaskLogService.updateById(log);
+                appiumTaskLogMapper.updateById(log);
                 appiumDevice.setStatus(1);
                 iAppiumDeviceService.updateById(appiumDevice);
             }
         } catch (Exception e) {
             e.printStackTrace();
             log.setStatus(3);
-            iAppiumTaskLogService.updateById(log);
+            appiumTaskLogMapper.updateById(log);
             appiumDevice.setStatus(1);
             iAppiumDeviceService.updateById(appiumDevice);
         }