Browse Source

opt: 错误任务更新

master
李永德 1 year ago
parent
commit
ea50de60ad
  1. 25
      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

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

@ -116,26 +116,21 @@ 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());
schBaseTask.setTask_status(TaskStatus.ISSUED.getCode()); // 判断是否是出错的任务
} else { for (int i = 0; ObjectUtil.isNotEmpty(errArr) && i < errArr.size(); i++) {
schBaseTask.setTask_status(TaskStatus.ISSUED.getCode()); JSONObject errObj = errArr.getJSONObject(i);
// 判断是否是出错的任务 String taskCode = errObj.getString("task_code");
for (int i = 0; i < errArr.size(); i++) { if (taskCode.equals(schBaseTask.getTask_code())) {
JSONObject errObj = errArr.getJSONObject(i); // 出错的任务就设置出错信息为备注,不是出错就设置下发
String taskCode = errObj.getString("task_code"); schBaseTask.setTask_status(TaskStatus.CREATED.getCode());
if (taskCode.equals(schBaseTask.getTask_code())) { schBaseTask.setRemark(errObj.getString("message"));
// 出错的任务就设置出错信息为备注,不是出错就设置下发 break;
schBaseTask.setTask_status(TaskStatus.CREATED.getCode());
schBaseTask.setRemark(errObj.getString("message"));
break;
}
} }
} }
} }

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