Browse Source

opt: 错误任务更新

master
李永德 1 year ago
parent
commit
ea50de60ad
  1. 7
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/AbstractTask.java
  2. 13
      lms/nladmin-system/nlsso-server/src/test/java/org/nl/point/test.java

7
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/AbstractTask.java

@ -116,18 +116,14 @@ public abstract class AbstractTask {
resultForAcs.setCode(HttpStatus.HTTP_BAD_REQUEST); resultForAcs.setCode(HttpStatus.HTTP_BAD_REQUEST);
resultForAcs.setMessage(e.getMessage()); resultForAcs.setMessage(e.getMessage());
} }
// todo: 可优化点:解除双层循环判断任务的完成性
// 如果下发完毕,就修改状态 // 如果下发完毕,就修改状态
if (resultForAcs.getCode() == 200) { if (resultForAcs.getCode() == 200) {
// 解析 // 解析
JSONArray errArr = resultForAcs.getErrArr(); JSONArray errArr = resultForAcs.getErrArr();
for (SchBaseTask schBaseTask : taskList) { for (SchBaseTask schBaseTask : taskList) {
if (errArr == null) {
schBaseTask.setTask_status(TaskStatus.ISSUED.getCode());
} else {
schBaseTask.setTask_status(TaskStatus.ISSUED.getCode()); schBaseTask.setTask_status(TaskStatus.ISSUED.getCode());
// 判断是否是出错的任务 // 判断是否是出错的任务
for (int i = 0; i < errArr.size(); i++) { for (int i = 0; ObjectUtil.isNotEmpty(errArr) && i < errArr.size(); i++) {
JSONObject errObj = errArr.getJSONObject(i); JSONObject errObj = errArr.getJSONObject(i);
String taskCode = errObj.getString("task_code"); String taskCode = errObj.getString("task_code");
if (taskCode.equals(schBaseTask.getTask_code())) { if (taskCode.equals(schBaseTask.getTask_code())) {
@ -138,7 +134,6 @@ public abstract class AbstractTask {
} }
} }
} }
}
taskService.updateBatchById(taskList); taskService.updateBatchById(taskList);
} }
return resultForAcs; return resultForAcs;

13
lms/nladmin-system/nlsso-server/src/test/java/org/nl/point/test.java

@ -1,7 +1,9 @@
package org.nl.point; package org.nl.point;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.checkerframework.checker.units.qual.A; import org.checkerframework.checker.units.qual.A;
@ -11,6 +13,8 @@ import org.nl.wms.ext.acs.service.dto.to.wms.ApplyDeviceDto;
import org.nl.wms.ext.acs.service.dto.to.wms.ApplyTaskRequest; import org.nl.wms.ext.acs.service.dto.to.wms.ApplyTaskRequest;
import org.nl.wms.sch.region.service.ISchBaseRegionService; import org.nl.wms.sch.region.service.ISchBaseRegionService;
import org.nl.wms.sch.region.service.dao.SchBaseRegion; import org.nl.wms.sch.region.service.dao.SchBaseRegion;
import org.nl.wms.sch.task.service.dao.SchBaseTask;
import org.nl.wms.sch.task_manage.task.core.TaskStatus;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -98,5 +102,14 @@ public class test {
JSONObject jsonObject = JSONObject.parseObject(s); JSONObject jsonObject = JSONObject.parseObject(s);
System.out.println(jsonObject); System.out.println(jsonObject);
} }
@Test
public void test05() {
JSONArray errArr = null;
for (int i = 0; ObjectUtil.isNotEmpty(errArr) && i < errArr.size(); i++) {
JSONObject errObj = errArr.getJSONObject(i);
System.out.println("1");
}
System.out.println("2");
}
} }

Loading…
Cancel
Save