代码更新
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
package org.nl.wms.sch.manage;
|
||||
|
||||
/**
|
||||
* Task状态:00生成 ,01:下发,02、执行中,03、完成
|
||||
*/
|
||||
public enum TaskStatusEnum {
|
||||
CREATED("1", "生成"),
|
||||
SURE_START("2", "确定起点"),
|
||||
@@ -10,7 +7,7 @@ public enum TaskStatusEnum {
|
||||
START_AND_POINT("4", "起点终点确认"),
|
||||
ISSUE("5", "下发"),
|
||||
EXECUTING("6", "执行中"),
|
||||
FINISHED("7", "完成");
|
||||
FINISHED("99", "完成");
|
||||
|
||||
private String name;
|
||||
private String code;
|
||||
|
||||
@@ -0,0 +1,243 @@
|
||||
package org.nl.wms.sch.tasks;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.common.utils.SecurityUtils;
|
||||
import org.nl.modules.system.util.CodeUtil;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.wms.sch.manage.AbstractAcsTask;
|
||||
import org.nl.wms.sch.manage.TaskStatusEnum;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class HtSendEmpVehicleTask extends AbstractAcsTask {
|
||||
private final String THIS_CLASS = HtSendEmpVehicleTask.class.getName();
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateTaskStatus(JSONObject taskObj, String status) {
|
||||
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task");
|
||||
WQLObject pointTab = WQLObject.getWQLObject("sch_base_point");
|
||||
|
||||
String task_id = taskObj.getString("task_id");
|
||||
JSONObject jsonTask = taskTab.query("task_id = '" + task_id + "'").uniqueResult(0);
|
||||
|
||||
if (StrUtil.equals(status, "0")) {
|
||||
// 取消删除任务
|
||||
taskTab.delete("task_id = '" + task_id + "'");
|
||||
}
|
||||
|
||||
if (TaskStatusEnum.EXECUTING.getCode().equals(status)) {
|
||||
// 更新任务状态为执行中
|
||||
jsonTask.put("task_status", TaskStatusEnum.EXECUTING.getCode());
|
||||
jsonTask.put("update_time", DateUtil.now());
|
||||
jsonTask.put("car_no", taskObj.getString("car_no"));
|
||||
taskTab.update(jsonTask);
|
||||
}
|
||||
|
||||
if (StrUtil.equals(status, TaskStatusEnum.FINISHED.getCode())) {
|
||||
// 更改任务状态为完成
|
||||
jsonTask.put("task_status", TaskStatusEnum.FINISHED.getCode());
|
||||
jsonTask.put("update_optid", SecurityUtils.getCurrentUserId());
|
||||
jsonTask.put("update_optname", SecurityUtils.getCurrentUsername());
|
||||
jsonTask.put("update_time", DateUtil.now());
|
||||
taskTab.update(jsonTask);
|
||||
|
||||
String point_code2 = jsonTask.getString("point_code2");
|
||||
JSONObject endPoint = pointTab.query("point_code = '" + point_code2 + "'").uniqueResult(0);
|
||||
//终点是叠盘架
|
||||
if (StrUtil.equals("DPJQB01", endPoint.getString("region_code"))) {
|
||||
Integer vehicle_qty = endPoint.getInteger("vehicle_qty");
|
||||
vehicle_qty += jsonTask.getInteger("vehicle_qty");
|
||||
endPoint.put("lock_type", "00");
|
||||
endPoint.put("vehicle_qty", vehicle_qty);
|
||||
endPoint.put("point_status", "1");
|
||||
endPoint.put("vehicle_type", jsonTask.getString("vehicle_type"));
|
||||
pointTab.update(endPoint);
|
||||
} else {//非叠盘架
|
||||
endPoint.put("lock_type", "00");
|
||||
endPoint.put("vehicle_qty", jsonTask.getString("vehicle_qty"));
|
||||
endPoint.put("vehicle_type", jsonTask.getString("vehicle_type"));
|
||||
endPoint.put("point_status", "1");
|
||||
pointTab.update(endPoint);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String createTask(JSONObject form) {
|
||||
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task"); // 任务表
|
||||
WQLObject pointTab = WQLObject.getWQLObject("SCH_BASE_Point"); // 点位表
|
||||
WQLObject vehicleTab = WQLObject.getWQLObject("md_pb_vehicle"); // 载具表
|
||||
|
||||
String qty = form.getString("qty");
|
||||
String point_code1 = form.getString("point_code1");
|
||||
String point_code2 = "";
|
||||
|
||||
String task_id = "";
|
||||
|
||||
JSONObject jsonVehicle = vehicleTab.query("vehicle_code = '" + form.getString("vehicle_code") + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(jsonVehicle)) throw new BadRequestException("此载具号不存在");
|
||||
|
||||
// 1.判断货梯是否有任务,如果有生成起点确定的任务
|
||||
// 空托盘一楼到二楼固定点位:SSX01A1 , SSX02A1
|
||||
|
||||
//判断SSX01A1是否有任务没有则判断其他的三个点位
|
||||
boolean ssx_1 = this.isTask("SSX01A1");
|
||||
if (ssx_1) {
|
||||
String like = "SSX01%";
|
||||
|
||||
JSONArray taskArrNum = new JSONArray();
|
||||
JSONArray pointArr = pointTab.query("region_id = '" + RegionTypeEnum.SSX.getId() + "' and is_used = '1' and is_delete = '0' and point_code like '" + like + "'").getResultJSONArray(0);
|
||||
|
||||
for (int i = 0; i < pointArr.size(); i++) {
|
||||
JSONObject json = pointArr.getJSONObject(i);
|
||||
boolean is_empTask = this.isTask(json.getString("point_code"));
|
||||
|
||||
if (!is_empTask) taskArrNum.add(json);
|
||||
}
|
||||
|
||||
if (taskArrNum.size() > 0) {
|
||||
|
||||
} else {
|
||||
point_code2 = "SSX01A1";
|
||||
}
|
||||
}
|
||||
|
||||
// 判断SSX02A1是否有任务没有则判断其他的三个点位
|
||||
if (ObjectUtil.isEmpty(point_code2)) {
|
||||
boolean ssx_2 = this.isTask("SSX02A1");
|
||||
if (ssx_2) {
|
||||
String like = "SSX02%";
|
||||
|
||||
JSONArray taskArrNum = new JSONArray();
|
||||
JSONArray pointArr = pointTab.query("region_id = '" + RegionTypeEnum.SSX.getId() + "' and is_used = '1' and is_delete = '0' and point_code like '" + like + "'").getResultJSONArray(0);
|
||||
|
||||
for (int i = 0; i < pointArr.size(); i++) {
|
||||
JSONObject json = pointArr.getJSONObject(i);
|
||||
boolean is_empTask = this.isTask(json.getString("point_code"));
|
||||
|
||||
if (!is_empTask) taskArrNum.add(json);
|
||||
}
|
||||
|
||||
if (taskArrNum.size() > 0) {
|
||||
|
||||
} else {
|
||||
point_code2 = "SSX02A1";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 如果此时point_code2为空则生成起点确认的任务
|
||||
if (ObjectUtil.isEmpty(point_code2)) {
|
||||
JSONObject jsonTask = new JSONObject();
|
||||
jsonTask.put("task_id", IdUtil.getSnowflake(1,1).nextId());
|
||||
jsonTask.put("task_code", CodeUtil.getNewCode("TASK_CODE"));
|
||||
jsonTask.put("task_type", "");
|
||||
jsonTask.put("task_status", "2");
|
||||
jsonTask.put("point_code1", point_code1);
|
||||
jsonTask.put("vehicle_type", jsonVehicle.getString("vehicle_type"));
|
||||
jsonTask.put("vehicle_qty", qty);
|
||||
jsonTask.put("vehicle_code", jsonVehicle.getString("vehicle_code"));
|
||||
jsonTask.put("priority", "1");
|
||||
jsonTask.put("handle_class", THIS_CLASS);
|
||||
jsonTask.put("sort_seq", "1");
|
||||
jsonTask.put("acs_task_type", "1");
|
||||
jsonTask.put("create_time", DateUtil.now());
|
||||
taskTab.insert(jsonTask);
|
||||
task_id = jsonTask.getString("task_id");
|
||||
} else {
|
||||
// 说明货梯无任务:找终点
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("vehicle_type", jsonVehicle.getString("vehicle_type"));
|
||||
param.put("qty", qty);
|
||||
|
||||
|
||||
}
|
||||
|
||||
return task_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @discription 确定下一点位
|
||||
* @author ldjun
|
||||
* @created 2020年6月12日 下午6:01:06
|
||||
*/
|
||||
@Override
|
||||
public void findNextPoint() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void forceFinish(String task_id) {
|
||||
JSONObject taskObj = WQLObject.getWQLObject("SCH_BASE_Task").query("task_id = '" + task_id + "'").uniqueResult(0);
|
||||
this.updateTaskStatus(taskObj, TaskStatusEnum.FINISHED.getCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pullBack(String task_id) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel(String task_id) {
|
||||
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String endPoint(JSONObject param) {
|
||||
/*
|
||||
* 1.叠盘架有A对应货位 规则:如果暂存位能放下则放暂存位如果放不下则走2或3
|
||||
* 2.叠盘架A没有货位 则去叠盘架暂存位
|
||||
* 3.叠盘架暂存位没有货位则去养生A区
|
||||
*/
|
||||
WQLObject pointTab = WQLObject.getWQLObject("SCH_BASE_Point"); // 点位表
|
||||
|
||||
String vehicle_type = param.getString("vehicle_type");
|
||||
String qty = param.getString("qty");
|
||||
|
||||
// 1.找到对应类型的叠盘架
|
||||
// pointTab.query("region_id = '"+Ta+"'")
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean isTask(String point_code) {
|
||||
|
||||
WQLObject tab = WQLObject.getWQLObject("SCH_BASE_Task");
|
||||
|
||||
boolean result;
|
||||
|
||||
JSONObject jsonPointCode1 = tab.query("point_code1 = '" + point_code + "' and task_status <> '99' and is_delete = '0'").uniqueResult(0);
|
||||
JSONObject jsonPointCode2 = tab.query("point_code2 = '" + point_code + "' and task_status <> '99' and is_delete = '0'").uniqueResult(0);
|
||||
JSONObject jsonPointCode3 = tab.query("point_code3 = '" + point_code + "' and task_status <> '99' and is_delete = '0'").uniqueResult(0);
|
||||
JSONObject jsonPointCode4 = tab.query("point_code4 = '" + point_code + "' and task_status <> '99' and is_delete = '0'").uniqueResult(0);
|
||||
|
||||
if (ObjectUtil.isEmpty(jsonPointCode1) && ObjectUtil.isEmpty(jsonPointCode2) && ObjectUtil.isEmpty(jsonPointCode3) && ObjectUtil.isEmpty(jsonPointCode4)) {
|
||||
result = true;
|
||||
} else {
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user