yanps
6 months ago
14 changed files with 305 additions and 28 deletions
@ -0,0 +1,17 @@ |
|||
package org.nl.wms.sch.task_manage.task.core; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Getter; |
|||
|
|||
@Getter |
|||
@AllArgsConstructor |
|||
public enum TaskType { |
|||
|
|||
CARRY_TASK("搬运任务","1"), |
|||
REASSIGN_TASK("二次分配任务","2"); |
|||
|
|||
|
|||
private final String name; |
|||
private final String value; |
|||
|
|||
} |
@ -0,0 +1,166 @@ |
|||
package org.nl.wms.sch.task_manage.task.tasks.cnt; |
|||
|
|||
import cn.hutool.core.util.ObjectUtil; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.nl.common.enums.region.RegionEnum; |
|||
import org.nl.common.exception.BadRequestException; |
|||
import org.nl.system.service.notice.ISysNoticeService; |
|||
import org.nl.wms.ext.acs.service.dto.to.BaseResponse; |
|||
import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService; |
|||
import org.nl.wms.sch.group.service.dao.SchBaseVehiclematerialgroup; |
|||
import org.nl.wms.sch.point.service.ISchBasePointService; |
|||
import org.nl.wms.sch.point.service.dao.SchBasePoint; |
|||
import org.nl.wms.sch.task.service.ISchBaseTaskService; |
|||
import org.nl.wms.sch.task.service.ISchBaseTaskconfigService; |
|||
import org.nl.wms.sch.task.service.dao.SchBaseTask; |
|||
import org.nl.wms.sch.task.service.dao.SchBaseTaskconfig; |
|||
import org.nl.wms.sch.task_manage.AbstractTask; |
|||
import org.nl.wms.sch.task_manage.GeneralDefinition; |
|||
import org.nl.wms.sch.task_manage.enums.NoticeTypeEnum; |
|||
import org.nl.wms.sch.task_manage.enums.TaskFinishedTypeEnum; |
|||
import org.nl.wms.sch.task_manage.task.core.TaskStatus; |
|||
import org.nl.wms.util.PointUtils; |
|||
import org.nl.wms.util.TaskUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Slf4j |
|||
@Component(value = "FTGTask") |
|||
public class FTGTask extends AbstractTask { |
|||
|
|||
|
|||
private static final String TASK_CONFIG_CODE = "FTGTask"; |
|||
@Autowired |
|||
private ISchBasePointService pointService; |
|||
@Autowired |
|||
private ISchBaseTaskService taskService; |
|||
@Autowired |
|||
private ISchBaseTaskconfigService taskConfigService; |
|||
@Autowired |
|||
private ISysNoticeService noticeService; |
|||
@Autowired |
|||
private ISchBasePointService schBasePointService; |
|||
@Autowired |
|||
private ISchBaseVehiclematerialgroupService schBaseVehiclematerialgroupService; |
|||
|
|||
@Override |
|||
protected void create() throws BadRequestException { |
|||
// 获取任务
|
|||
List<SchBaseTask> tasks = taskService.findTasksByTaskStatus(TASK_CONFIG_CODE, TaskStatus.APPLY); |
|||
for (SchBaseTask task : tasks) { |
|||
TaskUtils.setUpdateByAcs(task); |
|||
// 找起点
|
|||
String requestParam = task.getRequest_param(); |
|||
JSONObject jsonObject = JSONObject.parseObject(requestParam); |
|||
// 根据对接位查找对应的载具类型
|
|||
SchBasePoint schBasePoint = schBasePointService.selectByRegionCode(RegionEnum.TRUBEND_SHELVES_3_1_1.getRegion_code(),task.getVehicle_code()); |
|||
if(ObjectUtil.isEmpty(schBasePoint)) continue; |
|||
jsonObject.put("vehicle_type", schBasePoint.getCan_vehicle_type()); |
|||
if (ObjectUtil.isEmpty(schBasePoint)) { |
|||
task.setRemark("未找到所需点位!"); |
|||
taskService.updateById(task); |
|||
// 消息通知
|
|||
noticeService.createNotice("未找到所需点位!", TASK_CONFIG_CODE + task.getTask_code(), |
|||
NoticeTypeEnum.WARN.getCode()); |
|||
continue; |
|||
} |
|||
|
|||
SchBaseVehiclematerialgroup schBaseVehiclematerialgroup = new SchBaseVehiclematerialgroup(); |
|||
schBaseVehiclematerialgroup.setVehicle_code(task.getVehicle_code()); |
|||
schBaseVehiclematerialgroup.setPoint_code(schBasePoint.getPoint_code()); |
|||
schBaseVehiclematerialgroupService.create(schBaseVehiclematerialgroup); |
|||
|
|||
// 设置终点并修改创建成功状态
|
|||
task.setPoint_code1(schBasePoint.getPoint_code()); |
|||
task.setVehicle_type(schBasePoint.getCan_vehicle_type()); |
|||
task.setRemark(""); |
|||
task.setTask_status(TaskStatus.CREATED.getCode()); |
|||
taskService.updateById(task); |
|||
|
|||
schBasePoint.setIng_task_code(task.getTask_code()); |
|||
PointUtils.setUpdateByAcs(schBasePoint); |
|||
pointService.updateById(schBasePoint); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
protected void updateStatus(String task_code, TaskStatus status) { |
|||
//TODO:完成任务的时候将int_task_code的清除
|
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void forceFinish(String task_code) { |
|||
SchBaseTask taskObj = taskService.getByCode(task_code); |
|||
if (ObjectUtil.isEmpty(taskObj)) { |
|||
throw new BadRequestException("该任务不存在"); |
|||
} |
|||
this.finishTask(taskObj, TaskFinishedTypeEnum.MANUAL_CONNECTOR); |
|||
} |
|||
|
|||
@Override |
|||
public void cancel(String task_code) { |
|||
//TODO:取消任务的时候将int_task_code的清除
|
|||
SchBaseTask taskObj = taskService.getByCode(task_code); |
|||
if (ObjectUtil.isEmpty(taskObj)) { |
|||
throw new BadRequestException("该任务不存在"); |
|||
} |
|||
this.cancelTask(taskObj, TaskFinishedTypeEnum.MANUAL_CONNECTOR); |
|||
} |
|||
|
|||
@Override |
|||
protected void feedbackTaskState(JSONObject param, SchBaseTask schBaseTask, BaseResponse result) { |
|||
|
|||
} |
|||
|
|||
public void finishTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) { |
|||
// 获取参数
|
|||
String startPoint = taskObj.getPoint_code1(); |
|||
SchBasePoint schBasePoint = pointService.selectByPointCode(startPoint); |
|||
// 起点清空
|
|||
if (ObjectUtil.isNotEmpty(schBasePoint)) { |
|||
PointUtils.updateByIngTaskCode(schBasePoint); |
|||
pointService.updateById(schBasePoint); |
|||
} |
|||
String point_code2 = taskObj.getPoint_code2(); |
|||
SchBasePoint schBasePoint2 = pointService.selectByPointCode(point_code2); |
|||
if (ObjectUtil.isNotEmpty(schBasePoint2)) { |
|||
PointUtils.updateByIngTaskCode(schBasePoint2); |
|||
pointService.updateById(schBasePoint2); |
|||
} |
|||
// 任务完成
|
|||
taskObj.setTask_status(TaskStatus.FINISHED.getCode()); |
|||
taskObj.setRemark(GeneralDefinition.TASK_FINISH); |
|||
taskObj.setFinished_type(taskFinishedType.getCode()); |
|||
TaskUtils.setUpdateByType(taskObj, taskFinishedType); |
|||
taskService.updateById(taskObj); |
|||
} |
|||
|
|||
public void cancelTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) { |
|||
// 获取参数
|
|||
String startPoint = taskObj.getPoint_code1(); |
|||
SchBasePoint schBasePoint = pointService.selectByPointCode(startPoint); |
|||
// 起点清空
|
|||
if (ObjectUtil.isNotEmpty(schBasePoint)) { |
|||
PointUtils.updateByIngTaskCode(schBasePoint); |
|||
pointService.updateById(schBasePoint); |
|||
} |
|||
String point_code2 = taskObj.getPoint_code2(); |
|||
SchBasePoint schBasePoint2 = pointService.selectByPointCode(point_code2); |
|||
if (ObjectUtil.isNotEmpty(schBasePoint2)) { |
|||
PointUtils.updateByIngTaskCode(schBasePoint2); |
|||
pointService.updateById(schBasePoint2); |
|||
} |
|||
taskObj.setTask_status(TaskStatus.CANCELED.getCode()); |
|||
taskObj.setRemark(GeneralDefinition.TASK_CANCEL); |
|||
taskObj.setTask_status(TaskStatus.CANCELED.getCode()); |
|||
taskObj.setFinished_type(taskFinishedType.getCode()); |
|||
TaskUtils.setUpdateByType(taskObj, taskFinishedType); |
|||
taskService.updateById(taskObj); |
|||
} |
|||
|
|||
} |
Loading…
Reference in new issue