李永德
2 years ago
4 changed files with 19 additions and 212 deletions
@ -1,196 +0,0 @@ |
|||||
package org.nl.wms.sch.tasks.sendEmpty; |
|
||||
|
|
||||
import cn.hutool.core.date.DateUtil; |
|
||||
import cn.hutool.core.util.ObjectUtil; |
|
||||
import cn.hutool.core.util.StrUtil; |
|
||||
import com.alibaba.fastjson.JSON; |
|
||||
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.core.bean.WQLObject; |
|
||||
import org.nl.wms.sch.SchTaskDto; |
|
||||
import org.nl.wms.sch.manage.AbstractAcsTask; |
|
||||
import org.nl.wms.sch.manage.TaskStatusEnum; |
|
||||
import org.nl.wms.sch.tasks.AcsTaskDto; |
|
||||
import org.springframework.stereotype.Service; |
|
||||
|
|
||||
import java.util.List; |
|
||||
|
|
||||
/** |
|
||||
* @author: lyd |
|
||||
* @description: 混碾送空盅 |
|
||||
* @Date: 2022/11/15 |
|
||||
*/ |
|
||||
@Service |
|
||||
@RequiredArgsConstructor |
|
||||
@Slf4j |
|
||||
public class HnSendEmpVehicleTask extends AbstractAcsTask { |
|
||||
private final String THIS_CLASS = HnSendEmpVehicleTask.class.getName(); |
|
||||
/** |
|
||||
* 添加任务进行下发 |
|
||||
* |
|
||||
* @return |
|
||||
*/ |
|
||||
@Override |
|
||||
public List<AcsTaskDto> addTask() { |
|
||||
return null; |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* @param taskObj 代表一条任务对象 |
|
||||
* @param status 代表wcs任务完成状态: //0:acs,取消,:执行中,2:完成
|
|
||||
* @return |
|
||||
* @discription wcs请求wms任务完成状态反馈接口, 比如agv从a点往b点走。生成任务的时候绑定b的物料信息,任务完成的时候,清除a的物料信息 |
|
||||
* @author ldjun |
|
||||
* @created 2019年4月17日 下午8:51:50 |
|
||||
*/ |
|
||||
@Override |
|
||||
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"); |
|
||||
String point_code2 = taskObj.getString("point_code2"); |
|
||||
JSONObject jsonTask = taskTab.query("task_id = '" + task_id + "'").uniqueResult(0); |
|
||||
|
|
||||
if (StrUtil.equals(status, "0")) { |
|
||||
// 取消删除任务
|
|
||||
if (StrUtil.equals(jsonTask.getString("task_status"), TaskStatusEnum.FINISHED.getCode())) { |
|
||||
throw new BadRequestException("已完成不能取消!"); |
|
||||
} |
|
||||
// 解锁终点位置
|
|
||||
if (ObjectUtil.isNotEmpty(point_code2)) { // 未找到终点的取消只需要完成任务就行
|
|
||||
JSONObject point2 = pointTab.query("point_code = '" + point_code2 + "'").uniqueResult(0); |
|
||||
point2.put("lock_type", "1"); |
|
||||
pointTab.update(point2); |
|
||||
} |
|
||||
// 任务设置为完成
|
|
||||
jsonTask.put("task_status", TaskStatusEnum.FINISHED.getCode()); |
|
||||
jsonTask.put("remark", "已取消"); |
|
||||
taskTab.update(jsonTask); |
|
||||
} |
|
||||
|
|
||||
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); |
|
||||
// 释放点位
|
|
||||
if (ObjectUtil.isNotEmpty(point_code2)) { // 防止只有确定起点的任务完成
|
|
||||
JSONObject point_2 = pointTab.query("point_code = '" + point_code2 + "'").uniqueResult(0); |
|
||||
point_2.put("lock_type", "1"); |
|
||||
point_2.put("point_status", "2"); |
|
||||
point_2.put("vehicle_code", jsonTask.getString("vehicle_code")); |
|
||||
point_2.put("vehicle_qty", "1"); // 混碾送的空盅一个放一个位置,所以只设一个
|
|
||||
point_2.put("instorage_time", DateUtil.now()); |
|
||||
point_2.put("is_full", "1"); |
|
||||
point_2.put("ivt_qty", "0"); |
|
||||
point_2.put("pcsn", ""); |
|
||||
point_2.put("material_id", ""); |
|
||||
point_2.put("standing_time", "0"); |
|
||||
pointTab.update(point_2); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* @param form 创建任务需要的参数 |
|
||||
* @return 返回任务标识 |
|
||||
*/ |
|
||||
@Override |
|
||||
public String createTask(JSONObject form) { |
|
||||
// 送到困料货架,盅
|
|
||||
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task"); // 任务表
|
|
||||
|
|
||||
String point_code1 = form.getString("point_code1"); |
|
||||
|
|
||||
SchTaskDto dto = SchTaskDto.builder().task_id(org.nl.wms.util.IdUtil.getLongId()) |
|
||||
.task_code(CodeUtil.getNewCode("TASK_CODE")) |
|
||||
.task_type("") |
|
||||
.task_name("分拣空钢托盘入库") |
|
||||
.task_status(TaskStatusEnum.SURE_START.getCode()) |
|
||||
.point_code1(point_code1) |
|
||||
.vehicle_code(form.getString("vehicle_code")) |
|
||||
.vehicle_type(form.getString("vehicle_type")) |
|
||||
.vehicle_qty(form.getIntValue("qty")) |
|
||||
.handle_class(THIS_CLASS) |
|
||||
.create_time(DateUtil.now()) |
|
||||
.build(); |
|
||||
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto)); |
|
||||
taskTab.insert(json); |
|
||||
this.immediateNotifyAcs(); |
|
||||
return String.valueOf(dto.getTask_id()); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* @return |
|
||||
* @discription 确定下一点位 |
|
||||
* @author ldjun |
|
||||
* @created 2020年6月12日 下午6:01:06 |
|
||||
*/ |
|
||||
@Override |
|
||||
public void findNextPoint() { |
|
||||
// 找困料货架
|
|
||||
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task"); |
|
||||
WQLObject pointTab = WQLObject.getWQLObject("sch_base_point"); |
|
||||
|
|
||||
JSONArray taskArr = taskTab.query("handle_class = '" + THIS_CLASS + "'and is_delete = '0' and task_status = '2'").getResultJSONArray(0); |
|
||||
for (int i = 0; i < taskArr.size(); i++) { |
|
||||
JSONObject taskObj = taskArr.getJSONObject(i); |
|
||||
// 直接找
|
|
||||
JSONObject endPoint = pointTab.query("region_code = 'KLHJ' AND lock_type = '1' AND is_used='1' AND point_type = '1'").uniqueResult(0); |
|
||||
if (ObjectUtil.isEmpty(endPoint)) { |
|
||||
taskObj.put("remark", "困料货架无可用货位!"); |
|
||||
taskObj.put("task_status", TaskStatusEnum.SURE_START.getCode()); |
|
||||
taskObj.put("update_time", DateUtil.now()); |
|
||||
taskTab.update(taskObj); |
|
||||
} else { |
|
||||
taskObj.put("update_time", DateUtil.now()); |
|
||||
taskObj.put("point_code2", endPoint.getString("point_code")); |
|
||||
taskObj.put("task_status", TaskStatusEnum.START_AND_POINT.getCode()); |
|
||||
taskTab.update(taskObj); |
|
||||
|
|
||||
//锁住终点
|
|
||||
endPoint.put("task_id", taskObj.getString("task_id")); |
|
||||
endPoint.put("lock_type", "2"); |
|
||||
pointTab.update(endPoint); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* @param task_id 任务标识 |
|
||||
* @return |
|
||||
* @discription 强制结束完成任务 |
|
||||
* @author ldjun |
|
||||
* @created 2020年6月19日 上午10:34:58 |
|
||||
*/ |
|
||||
@Override |
|
||||
public void forceFinish(String task_id) { |
|
||||
|
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* 取消任务,货物搬回原点 |
|
||||
* |
|
||||
* @param task_id |
|
||||
*/ |
|
||||
@Override |
|
||||
public void cancel(String task_id) { |
|
||||
|
|
||||
} |
|
||||
} |
|
Loading…
Reference in new issue