|
|
@ -7,9 +7,11 @@ import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import org.nl.modules.common.exception.BadRequestException; |
|
|
|
import org.nl.modules.common.utils.SecurityUtils; |
|
|
|
import org.nl.modules.wql.core.bean.WQLObject; |
|
|
|
import org.nl.wms.sch.AcsUtil; |
|
|
|
import org.nl.wms.sch.task.AcsTaskDTO; |
|
|
|
import org.nl.wms.sch.task.util.TaskUtils; |
|
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
@ -51,7 +53,7 @@ public abstract class AbstractAcsTask { |
|
|
|
.query("is_delete = '0' AND task_status = " + TaskStatus.START_AND_END.value() + " AND handle_class = '" + this.getClass().getName() + "'") |
|
|
|
.getResultJSONArray(0); |
|
|
|
|
|
|
|
ArrayList<AcsTaskDTO> acsTasks = new ArrayList<>(); |
|
|
|
ArrayList<AcsTaskDTO> acs_tasks = new ArrayList<>(); |
|
|
|
for (Object o : tasks) { |
|
|
|
JSONObject task = (JSONObject) o; |
|
|
|
|
|
|
@ -68,11 +70,13 @@ public abstract class AbstractAcsTask { |
|
|
|
.remark(task.getString("remark")) |
|
|
|
.build(); |
|
|
|
|
|
|
|
acsTasks.add(acsTask); |
|
|
|
acs_tasks.add(acsTask); |
|
|
|
} |
|
|
|
|
|
|
|
return acsTasks; |
|
|
|
}; |
|
|
|
return acs_tasks; |
|
|
|
} |
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
/** |
|
|
|
* @param taskObj 代表一条任务对象 |
|
|
@ -145,16 +149,32 @@ public abstract class AbstractAcsTask { |
|
|
|
*/ |
|
|
|
public JSONObject immediateNotifyAcs(String taskId) { |
|
|
|
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task"); |
|
|
|
JSONArray tasks = taskTable |
|
|
|
JSONObject task = taskTable |
|
|
|
.query("task_id = " + taskId) |
|
|
|
.getResultJSONArray(0); |
|
|
|
.uniqueResult(0); |
|
|
|
|
|
|
|
if (ObjectUtil.isNotEmpty(tasks)) { |
|
|
|
String taskStatus = ((JSONObject) tasks.get(0)).getString("task_status"); |
|
|
|
if (!StrUtil.equals(taskStatus, TaskStatus.START_AND_END.value())) { |
|
|
|
throw new BadRequestException("只能下发已确认起点和终点的任务"); |
|
|
|
if (ObjectUtil.isNotEmpty(task)) { |
|
|
|
String task_status = task.getString("task_status"); |
|
|
|
if (!StrUtil.equals(task_status, TaskStatus.START_AND_END.value())) { |
|
|
|
throw new BadRequestException("只能下发 [确认起点和终点] 的任务!"); |
|
|
|
} |
|
|
|
|
|
|
|
AcsTaskDTO acs_task = AcsTaskDTO |
|
|
|
.builder() |
|
|
|
.task_id(task.getString("task_id")) |
|
|
|
.task_code(task.getString("task_code")) |
|
|
|
.task_type(task.getString("acs_task_type")) |
|
|
|
.start_device_code(task.getString("point_code1")) |
|
|
|
.next_device_code(task.getString("point_code2")) |
|
|
|
.vehicle_code(task.getString("vehicle_code")) |
|
|
|
.vehicle_type(task.getString("vehicle_type")) |
|
|
|
.priority(task.getString("priority")) |
|
|
|
.remark(task.getString("remark")) |
|
|
|
.build(); |
|
|
|
|
|
|
|
JSONArray tasks = new JSONArray() {{ |
|
|
|
add(acs_task); |
|
|
|
}}; |
|
|
|
JSONObject result = AcsUtil.notifyAcs("api/wms/task", tasks); |
|
|
|
|
|
|
|
String status = result.getString("status"); |
|
|
@ -169,8 +189,8 @@ public abstract class AbstractAcsTask { |
|
|
|
JSONObject taskObj = new JSONObject(); |
|
|
|
taskObj.put("task_id", ((JSONObject) item).getString("task_id")); |
|
|
|
taskObj.put("task_status", TaskStatus.ISSUE.value()); |
|
|
|
taskObj.put("remark", "下发成功"); |
|
|
|
taskObj.put("update_time", DateUtil.now()); |
|
|
|
taskObj.put("remark", "下发成功!"); |
|
|
|
TaskUtils.addCurrentUpdateColum(taskObj); |
|
|
|
taskTable.update(taskObj); |
|
|
|
}); |
|
|
|
} else {//下发失败
|
|
|
@ -178,8 +198,8 @@ public abstract class AbstractAcsTask { |
|
|
|
JSONObject taskObj = new JSONObject(); |
|
|
|
taskObj.put("task_id", ((JSONObject) item).getString("task_id")); |
|
|
|
// taskObj.put("task_status", TaskStatusEnum.ISSUE.getCode());
|
|
|
|
taskObj.put("remark", "下发失败:" + message); |
|
|
|
taskObj.put("update_time", DateUtil.now()); |
|
|
|
taskObj.put("remark", "下发失败:" + message); |
|
|
|
TaskUtils.addCurrentUpdateColum(taskObj); |
|
|
|
taskTable.update(taskObj); |
|
|
|
}); |
|
|
|
} |
|
|
@ -188,8 +208,8 @@ public abstract class AbstractAcsTask { |
|
|
|
//处理下发失败的任务
|
|
|
|
for (int i = 0; i < errArr.size(); i++) { |
|
|
|
JSONObject taskObj = errArr.getJSONObject(i); |
|
|
|
taskObj.put("remark", "下发失败:"+taskObj.getString("message")); |
|
|
|
taskObj.put("update_time", DateUtil.now()); |
|
|
|
taskObj.put("remark", "下发失败:" + taskObj.getString("message")); |
|
|
|
TaskUtils.addCurrentUpdateColum(taskObj); |
|
|
|
taskTable.update(taskObj); |
|
|
|
} |
|
|
|
} |
|
|
|