26 changed files with 1183 additions and 448 deletions
@ -0,0 +1,38 @@ |
|||
package org.nl.wms.basedata.eum; |
|||
|
|||
import lombok.RequiredArgsConstructor; |
|||
|
|||
import java.util.Arrays; |
|||
import java.util.stream.Collectors; |
|||
|
|||
/** |
|||
* 静置状态 |
|||
* |
|||
* @author zhangjiangwei |
|||
* @date 2023/05/04 09:26 |
|||
*/ |
|||
@RequiredArgsConstructor |
|||
public enum StandStatus { |
|||
|
|||
WITHOUT("无需静置", "1"), |
|||
STANDING("静置中", "2"), |
|||
COMPLETED("静置完成", "3"), |
|||
FORCE_COMPLETION("强制静置完成", "4"), |
|||
TIMEOUT("静置超时", "5"); |
|||
|
|||
|
|||
private final String label; |
|||
private final String value; |
|||
|
|||
public String label() { |
|||
return this.label; |
|||
} |
|||
|
|||
public String value() { |
|||
return this.value; |
|||
} |
|||
|
|||
public static StandStatus get(String value) { |
|||
return Arrays.stream(StandStatus.values()).filter(vt -> vt.value.equals(value)).collect(Collectors.toList()).get(0); |
|||
} |
|||
} |
@ -0,0 +1,228 @@ |
|||
package org.nl.wms.sch.task.to.pack; |
|||
|
|||
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 org.nl.modules.common.exception.BadRequestException; |
|||
import org.nl.modules.wql.WQL; |
|||
import org.nl.modules.wql.core.bean.WQLObject; |
|||
import org.nl.wms.basedata.eum.TrueOrFalse; |
|||
import org.nl.wms.common.PickType; |
|||
import org.nl.wms.sch.manage.*; |
|||
import org.nl.wms.sch.task.util.TaskUtils; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* @author zhangjiangwei |
|||
* @date 2023/05/04 10:05 |
|||
*/ |
|||
@RequiredArgsConstructor |
|||
@Component |
|||
public class BTHCToPackageTask extends AbstractAcsTask { |
|||
|
|||
@Override |
|||
public void updateTaskStatus(JSONObject task, String status) { |
|||
if (TaskStatus.EXECUTING.value().equals(status)) { |
|||
task.put("task_status", TaskStatus.EXECUTING.value()); |
|||
TaskUtils.addACSUpdateColum(task); |
|||
WQLObject.getWQLObject("sch_base_task").update(task); |
|||
} else if (TaskStatus.FINISHED.value().equals(status)) { |
|||
this.finishTask(task, OperationType.AUTO); |
|||
} else if (TaskStatus.CANCELLED.value().equals(status)) { |
|||
this.cancelTask(task, OperationType.AUTO); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public String createTask(JSONObject form) { |
|||
JSONObject point = form.getJSONObject("point"); |
|||
JSONObject vd = form.getJSONObject("vd"); |
|||
|
|||
JSONObject pn = TaskUtils.buildPN(PickType.CP, vd.getLongValue("qty"), vd.getLongValue("workorder_id")); |
|||
WQLObject.getWQLObject("das_produce_number").insert(pn); |
|||
|
|||
JSONObject task = TaskUtils.buildTask( |
|||
"半托缓存区去包装", |
|||
TaskType.TO_PACKAGE.value(), |
|||
TaskStatus.SURE_START.value(), |
|||
point.getString("point_code"), |
|||
null, |
|||
pn.getLongValue("data_id"), |
|||
vd.getString("material_id"), |
|||
vd.getString("vehicle_type"), |
|||
vd.getString("vehicle_code"), |
|||
1, |
|||
BTHCToPackageTask.class.getName(), |
|||
form.getString("create_mode"), |
|||
form.getString("request_param"), |
|||
form.getString("create_id"), |
|||
form.getString("create_name") |
|||
); |
|||
WQLObject.getWQLObject("sch_base_task").insert(task); |
|||
|
|||
point.put("lock_type", LockType.TASK_LOCKED.value()); |
|||
point.put("task_code", task.getString("task_code")); |
|||
TaskUtils.addFormUpdateColum(point, form); |
|||
WQLObject.getWQLObject("sch_base_point").update(point); |
|||
|
|||
return task.getString("task_code"); |
|||
} |
|||
|
|||
|
|||
@Override |
|||
public void findNextPoint() { |
|||
WQLObject task_table = WQLObject.getWQLObject("sch_base_task"); |
|||
JSONArray tasks = task_table |
|||
.query("is_delete = '0' AND task_status = '" + TaskStatus.SURE_START.value() + "' AND handle_class = '" + BTHCToPackageTask.class.getName() + "'", "priority DESC, create_time ASC") |
|||
.getResultJSONArray(0); |
|||
|
|||
if (ObjectUtil.isNotEmpty(tasks)) { |
|||
WQLObject point_table = WQLObject.getWQLObject("sch_base_point"); |
|||
|
|||
for (int i = 0; i < tasks.size(); i++) { |
|||
JSONObject task = tasks.getJSONObject(i); |
|||
|
|||
JSONObject point = WQL |
|||
.getWO("TO_PACKAGE_TASK") |
|||
.addParam("flag", "1") |
|||
.process() |
|||
.uniqueResult(0); |
|||
|
|||
if (ObjectUtil.isNotEmpty(point)) { |
|||
task.put("task_status", TaskStatus.START_AND_END.value()); |
|||
task.put("point_code2", point.getString("point_code")); |
|||
task.put("remark", ""); |
|||
TaskUtils.addAutoUpdateColum(task); |
|||
task_table.update(task); |
|||
|
|||
point.put("lock_type", LockType.TASK_LOCKED.value()); |
|||
point.put("task_code", task.getString("task_code")); |
|||
TaskUtils.addAutoUpdateColum(point); |
|||
point_table.update(point); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
@Override |
|||
public void forceFinish(String task_id) { |
|||
JSONObject task = WQLObject.getWQLObject("sch_base_task").query("task_id = " + task_id).uniqueResult(0); |
|||
if (ObjectUtil.isEmpty(task)) { |
|||
throw new BadRequestException("未找到任务!"); |
|||
} |
|||
this.finishTask(task, OperationType.MANUAL); |
|||
} |
|||
|
|||
|
|||
@Override |
|||
public void cancel(String task_id) { |
|||
JSONObject task = WQLObject.getWQLObject("sch_base_task").query("task_id = " + task_id).uniqueResult(0); |
|||
if (ObjectUtil.isEmpty(task)) { |
|||
throw new BadRequestException("未找到任务!"); |
|||
} |
|||
this.cancelTask(task, OperationType.MANUAL); |
|||
} |
|||
|
|||
|
|||
public void cancelTask(JSONObject task, OperationType operation_type) { |
|||
if (task.getIntValue("task_status") < Integer.parseInt(TaskStatus.FINISHED.value())) { |
|||
task.put("task_status", TaskStatus.CANCELLED.value()); |
|||
if (operation_type == OperationType.AUTO) { |
|||
TaskUtils.addACSUpdateColum(task); |
|||
} else if (operation_type == OperationType.MANUAL) { |
|||
TaskUtils.addCurrentUpdateColum(task); |
|||
} |
|||
WQLObject.getWQLObject("sch_base_task").update(task); |
|||
|
|||
WQLObject point_table = WQLObject.getWQLObject("sch_base_point"); |
|||
|
|||
String point_code1 = task.getString("point_code1"); |
|||
if (StrUtil.isNotBlank(point_code1)) { |
|||
JSONObject point1 = point_table.query("point_code = '" + point_code1 + "'").uniqueResult(0); |
|||
if (LockType.TASK_LOCKED.value().equals(point1.getString("lock_type")) |
|||
&& task.getString("task_code").equals(point1.getString("task_code"))) { |
|||
point1.put("lock_type", LockType.UNLOCKED.value()); |
|||
point1.put("task_code", ""); |
|||
if (operation_type == OperationType.AUTO) { |
|||
TaskUtils.addACSUpdateColum(point1); |
|||
} else if (operation_type == OperationType.MANUAL) { |
|||
TaskUtils.addCurrentUpdateColum(point1); |
|||
} |
|||
point_table.update(point1); |
|||
} |
|||
} |
|||
|
|||
String point_code2 = task.getString("point_code2"); |
|||
if (StrUtil.isNotBlank(point_code2)) { |
|||
JSONObject point2 = new JSONObject(); |
|||
point2.put("lock_type", LockType.UNLOCKED.value()); |
|||
point2.put("task_code", ""); |
|||
if (operation_type == OperationType.AUTO) { |
|||
TaskUtils.addACSUpdateColum(point2); |
|||
} else if (operation_type == OperationType.MANUAL) { |
|||
TaskUtils.addCurrentUpdateColum(point2); |
|||
} |
|||
point_table.update(point2, "point_code = '" + point_code2 + "'"); |
|||
} |
|||
|
|||
WQLObject.getWQLObject("das_produce_number").delete("data_id = " + task.getLongValue("group_id")); |
|||
} |
|||
} |
|||
|
|||
|
|||
public void finishTask(JSONObject task, OperationType operation_type) { |
|||
int current_task_status = task.getIntValue("task_status"); |
|||
if (current_task_status < Integer.parseInt(TaskStatus.FINISHED.value())) { |
|||
if (operation_type == OperationType.MANUAL |
|||
&& current_task_status < Integer.parseInt(TaskStatus.START_AND_END.value())) { |
|||
throw new BadRequestException("只能手动完成 [确认起点和终点] 之后的任务!"); |
|||
} |
|||
|
|||
task.put("task_status", TaskStatus.FINISHED.value()); |
|||
if (operation_type == OperationType.AUTO) { |
|||
TaskUtils.addACSUpdateColum(task); |
|||
} else if (operation_type == OperationType.MANUAL) { |
|||
TaskUtils.addCurrentUpdateColum(task); |
|||
} |
|||
WQLObject.getWQLObject("sch_base_task").update(task); |
|||
|
|||
WQLObject point_table = WQLObject.getWQLObject("sch_base_point"); |
|||
|
|||
String point_code1 = task.getString("point_code1"); |
|||
if (StrUtil.isNotBlank(point_code1)) { |
|||
JSONObject point1 = point_table.query("point_code = '" + point_code1 + "'").uniqueResult(0); |
|||
if (ObjectUtil.isNotEmpty(point1) |
|||
&& LockType.TASK_LOCKED.value().equals(point1.getString("lock_type")) |
|||
&& task.getString("task_code").equals(point1.getString("task_code"))) { |
|||
point1.put("lock_type", LockType.UNLOCKED.value()); |
|||
point1.put("task_code", ""); |
|||
point1.put("vehicle_type", ""); |
|||
point1.put("vehicle_code", ""); |
|||
point1.put("point_status", PointStatus.EMPTY.value()); |
|||
if (operation_type == OperationType.AUTO) { |
|||
TaskUtils.addACSUpdateColum(point1); |
|||
} else if (operation_type == OperationType.MANUAL) { |
|||
TaskUtils.addCurrentUpdateColum(point1); |
|||
} |
|||
point_table.update(point1); |
|||
} |
|||
} |
|||
|
|||
String point_code2 = task.getString("point_code2"); |
|||
if (StrUtil.isNotBlank(point_code2)) { |
|||
JSONObject point2 = new JSONObject(); |
|||
point2.put("lock_type", LockType.UNLOCKED.value()); |
|||
point2.put("task_code", ""); |
|||
if (operation_type == OperationType.AUTO) { |
|||
TaskUtils.addACSUpdateColum(point2); |
|||
} else if (operation_type == OperationType.MANUAL) { |
|||
TaskUtils.addCurrentUpdateColum(point2); |
|||
} |
|||
point_table.update(point2, "point_code = '" + point_code2 + "'"); |
|||
} |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,230 @@ |
|||
package org.nl.wms.sch.task.to.pack; |
|||
|
|||
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 org.nl.modules.common.exception.BadRequestException; |
|||
import org.nl.modules.wql.WQL; |
|||
import org.nl.modules.wql.core.bean.WQLObject; |
|||
import org.nl.wms.basedata.eum.TrueOrFalse; |
|||
import org.nl.wms.common.PickType; |
|||
import org.nl.wms.sch.manage.*; |
|||
import org.nl.wms.sch.task.util.TaskUtils; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* @author zhangjiangwei |
|||
* @date 2023/05/04 09:40 |
|||
*/ |
|||
@RequiredArgsConstructor |
|||
@Component |
|||
public class FJToPackageTask extends AbstractAcsTask { |
|||
|
|||
@Override |
|||
public void updateTaskStatus(JSONObject task, String status) { |
|||
if (TaskStatus.EXECUTING.value().equals(status)) { |
|||
task.put("task_status", TaskStatus.EXECUTING.value()); |
|||
TaskUtils.addACSUpdateColum(task); |
|||
WQLObject.getWQLObject("sch_base_task").update(task); |
|||
} else if (TaskStatus.FINISHED.value().equals(status)) { |
|||
this.finishTask(task, OperationType.AUTO); |
|||
} else if (TaskStatus.CANCELLED.value().equals(status)) { |
|||
this.cancelTask(task, OperationType.AUTO); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public String createTask(JSONObject form) { |
|||
JSONObject point = form.getJSONObject("point"); |
|||
JSONObject work_order = form.getJSONObject("workorder"); |
|||
int priority = TrueOrFalse.trueOrFalse(work_order.getString("is_urgent")) ? 50 : 1; |
|||
JSONObject vd = form.getJSONObject("vd"); |
|||
|
|||
JSONObject pn = TaskUtils.buildPN(PickType.CP, vd.getLongValue("qty"), vd.getLongValue("workorder_id")); |
|||
WQLObject.getWQLObject("das_produce_number").insert(pn); |
|||
|
|||
JSONObject task = TaskUtils.buildTask( |
|||
"分拣区去包装", |
|||
TaskType.TO_PACKAGE.value(), |
|||
TaskStatus.SURE_START.value(), |
|||
point.getString("point_code"), |
|||
null, |
|||
pn.getLongValue("data_id"), |
|||
vd.getString("material_id"), |
|||
vd.getString("vehicle_type"), |
|||
vd.getString("vehicle_code"), |
|||
priority, |
|||
FJToPackageTask.class.getName(), |
|||
form.getString("create_mode"), |
|||
form.getString("request_param"), |
|||
form.getString("create_id"), |
|||
form.getString("create_name") |
|||
); |
|||
WQLObject.getWQLObject("sch_base_task").insert(task); |
|||
|
|||
point.put("lock_type", LockType.TASK_LOCKED.value()); |
|||
point.put("task_code", task.getString("task_code")); |
|||
TaskUtils.addFormUpdateColum(point, form); |
|||
WQLObject.getWQLObject("sch_base_point").update(point); |
|||
|
|||
return task.getString("task_code"); |
|||
} |
|||
|
|||
|
|||
@Override |
|||
public void findNextPoint() { |
|||
WQLObject task_table = WQLObject.getWQLObject("sch_base_task"); |
|||
JSONArray tasks = task_table |
|||
.query("is_delete = '0' AND task_status = '" + TaskStatus.SURE_START.value() + "' AND handle_class = '" + FJToPackageTask.class.getName() + "'", "priority DESC, create_time ASC") |
|||
.getResultJSONArray(0); |
|||
|
|||
if (ObjectUtil.isNotEmpty(tasks)) { |
|||
WQLObject point_table = WQLObject.getWQLObject("sch_base_point"); |
|||
|
|||
for (int i = 0; i < tasks.size(); i++) { |
|||
JSONObject task = tasks.getJSONObject(i); |
|||
|
|||
JSONObject point = WQL |
|||
.getWO("TO_PACKAGE_TASK") |
|||
.addParam("flag", "1") |
|||
.process() |
|||
.uniqueResult(0); |
|||
|
|||
if (ObjectUtil.isNotEmpty(point)) { |
|||
task.put("task_status", TaskStatus.START_AND_END.value()); |
|||
task.put("point_code2", point.getString("point_code")); |
|||
task.put("remark", ""); |
|||
TaskUtils.addAutoUpdateColum(task); |
|||
task_table.update(task); |
|||
|
|||
point.put("lock_type", LockType.TASK_LOCKED.value()); |
|||
point.put("task_code", task.getString("task_code")); |
|||
TaskUtils.addAutoUpdateColum(point); |
|||
point_table.update(point); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
@Override |
|||
public void forceFinish(String task_id) { |
|||
JSONObject task = WQLObject.getWQLObject("sch_base_task").query("task_id = " + task_id).uniqueResult(0); |
|||
if (ObjectUtil.isEmpty(task)) { |
|||
throw new BadRequestException("未找到任务!"); |
|||
} |
|||
this.finishTask(task, OperationType.MANUAL); |
|||
} |
|||
|
|||
|
|||
@Override |
|||
public void cancel(String task_id) { |
|||
JSONObject task = WQLObject.getWQLObject("sch_base_task").query("task_id = " + task_id).uniqueResult(0); |
|||
if (ObjectUtil.isEmpty(task)) { |
|||
throw new BadRequestException("未找到任务!"); |
|||
} |
|||
this.cancelTask(task, OperationType.MANUAL); |
|||
} |
|||
|
|||
|
|||
public void cancelTask(JSONObject task, OperationType operation_type) { |
|||
if (task.getIntValue("task_status") < Integer.parseInt(TaskStatus.FINISHED.value())) { |
|||
task.put("task_status", TaskStatus.CANCELLED.value()); |
|||
if (operation_type == OperationType.AUTO) { |
|||
TaskUtils.addACSUpdateColum(task); |
|||
} else if (operation_type == OperationType.MANUAL) { |
|||
TaskUtils.addCurrentUpdateColum(task); |
|||
} |
|||
WQLObject.getWQLObject("sch_base_task").update(task); |
|||
|
|||
WQLObject point_table = WQLObject.getWQLObject("sch_base_point"); |
|||
|
|||
String point_code1 = task.getString("point_code1"); |
|||
if (StrUtil.isNotBlank(point_code1)) { |
|||
JSONObject point1 = point_table.query("point_code = '" + point_code1 + "'").uniqueResult(0); |
|||
if (LockType.TASK_LOCKED.value().equals(point1.getString("lock_type")) |
|||
&& task.getString("task_code").equals(point1.getString("task_code"))) { |
|||
point1.put("lock_type", LockType.UNLOCKED.value()); |
|||
point1.put("task_code", ""); |
|||
if (operation_type == OperationType.AUTO) { |
|||
TaskUtils.addACSUpdateColum(point1); |
|||
} else if (operation_type == OperationType.MANUAL) { |
|||
TaskUtils.addCurrentUpdateColum(point1); |
|||
} |
|||
point_table.update(point1); |
|||
} |
|||
} |
|||
|
|||
String point_code2 = task.getString("point_code2"); |
|||
if (StrUtil.isNotBlank(point_code2)) { |
|||
JSONObject point2 = new JSONObject(); |
|||
point2.put("lock_type", LockType.UNLOCKED.value()); |
|||
point2.put("task_code", ""); |
|||
if (operation_type == OperationType.AUTO) { |
|||
TaskUtils.addACSUpdateColum(point2); |
|||
} else if (operation_type == OperationType.MANUAL) { |
|||
TaskUtils.addCurrentUpdateColum(point2); |
|||
} |
|||
point_table.update(point2, "point_code = '" + point_code2 + "'"); |
|||
} |
|||
|
|||
WQLObject.getWQLObject("das_produce_number").delete("data_id = " + task.getLongValue("group_id")); |
|||
} |
|||
} |
|||
|
|||
|
|||
public void finishTask(JSONObject task, OperationType operation_type) { |
|||
int current_task_status = task.getIntValue("task_status"); |
|||
if (current_task_status < Integer.parseInt(TaskStatus.FINISHED.value())) { |
|||
if (operation_type == OperationType.MANUAL |
|||
&& current_task_status < Integer.parseInt(TaskStatus.START_AND_END.value())) { |
|||
throw new BadRequestException("只能手动完成 [确认起点和终点] 之后的任务!"); |
|||
} |
|||
|
|||
task.put("task_status", TaskStatus.FINISHED.value()); |
|||
if (operation_type == OperationType.AUTO) { |
|||
TaskUtils.addACSUpdateColum(task); |
|||
} else if (operation_type == OperationType.MANUAL) { |
|||
TaskUtils.addCurrentUpdateColum(task); |
|||
} |
|||
WQLObject.getWQLObject("sch_base_task").update(task); |
|||
|
|||
WQLObject point_table = WQLObject.getWQLObject("sch_base_point"); |
|||
|
|||
String point_code1 = task.getString("point_code1"); |
|||
if (StrUtil.isNotBlank(point_code1)) { |
|||
JSONObject point1 = point_table.query("point_code = '" + point_code1 + "'").uniqueResult(0); |
|||
if (ObjectUtil.isNotEmpty(point1) |
|||
&& LockType.TASK_LOCKED.value().equals(point1.getString("lock_type")) |
|||
&& task.getString("task_code").equals(point1.getString("task_code"))) { |
|||
point1.put("lock_type", LockType.UNLOCKED.value()); |
|||
point1.put("task_code", ""); |
|||
point1.put("vehicle_type", ""); |
|||
point1.put("vehicle_code", ""); |
|||
point1.put("point_status", PointStatus.EMPTY.value()); |
|||
if (operation_type == OperationType.AUTO) { |
|||
TaskUtils.addACSUpdateColum(point1); |
|||
} else if (operation_type == OperationType.MANUAL) { |
|||
TaskUtils.addCurrentUpdateColum(point1); |
|||
} |
|||
point_table.update(point1); |
|||
} |
|||
} |
|||
|
|||
String point_code2 = task.getString("point_code2"); |
|||
if (StrUtil.isNotBlank(point_code2)) { |
|||
JSONObject point2 = new JSONObject(); |
|||
point2.put("lock_type", LockType.UNLOCKED.value()); |
|||
point2.put("task_code", ""); |
|||
if (operation_type == OperationType.AUTO) { |
|||
TaskUtils.addACSUpdateColum(point2); |
|||
} else if (operation_type == OperationType.MANUAL) { |
|||
TaskUtils.addCurrentUpdateColum(point2); |
|||
} |
|||
point_table.update(point2, "point_code = '" + point_code2 + "'"); |
|||
} |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,40 @@ |
|||
[交易说明] |
|||
交易名: 去包装 |
|||
所属模块: |
|||
功能简述: |
|||
版权所有: |
|||
表引用: |
|||
版本经历: |
|||
|
|||
[数据库] |
|||
--指定数据库,为空采用默认值,默认为db.properties中列出的第一个库 |
|||
|
|||
[IO定义] |
|||
################################################# |
|||
## 表字段对应输入参数 |
|||
################################################# |
|||
输入.flag TYPEAS s_string |
|||
|
|||
[临时表] |
|||
--这边列出来的临时表就会在运行期动态创建 |
|||
|
|||
[临时变量] |
|||
--所有中间过程变量均可在此处定义 |
|||
|
|||
[业务过程] |
|||
|
|||
IF 输入.flag = "1" |
|||
QUERY |
|||
SELECT |
|||
* |
|||
FROM |
|||
sch_base_point |
|||
WHERE |
|||
is_used = '1' |
|||
AND lock_type = '1' |
|||
AND point_status = '0' |
|||
AND region_code = 'FJ' |
|||
AND point_type = '5' |
|||
ENDSELECT |
|||
ENDQUERY |
|||
ENDIF |
Binary file not shown.
Loading…
Reference in new issue