zhangzq
3 months ago
2 changed files with 200 additions and 0 deletions
@ -0,0 +1,26 @@ |
|||||
|
package org.nl.wms.ext.fab.service.dto; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* 设备点位配置信息 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class DeviceConfig { |
||||
|
/** |
||||
|
* 地面点位编码 |
||||
|
*/ |
||||
|
private String device_code; |
||||
|
/** |
||||
|
* 托盘类型 |
||||
|
*/ |
||||
|
private String vehicle_type; |
||||
|
/** |
||||
|
* 点位类型:"IN","OUT" |
||||
|
*/ |
||||
|
private String type; |
||||
|
/** |
||||
|
* 点位顺序:一共6个顺序 |
||||
|
*/ |
||||
|
private Integer num; |
||||
|
} |
@ -0,0 +1,174 @@ |
|||||
|
package org.nl.wms.sch.task_manage.task.tasks.pcoperation; |
||||
|
|
||||
|
import cn.hutool.core.util.ObjectUtil; |
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.nl.common.enums.GoodsEnum; |
||||
|
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.ext.fab.service.dto.SendMaterVo; |
||||
|
import org.nl.wms.ext.fab.service.dto.SendVehicleVo; |
||||
|
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 org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* sorting将空托盘放到线边库 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Component(value = "PcOperationSNTTask") |
||||
|
public class PcOperationSNTTask extends AbstractTask { |
||||
|
|
||||
|
|
||||
|
private static final String TASK_CONFIG_CODE = "PcOperationSNTTask"; |
||||
|
@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 |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
protected void create() throws BadRequestException { |
||||
|
// 获取任务
|
||||
|
List<SchBaseTask> tasks = taskService.findTasksByTaskStatus(TASK_CONFIG_CODE, TaskStatus.APPLY); |
||||
|
|
||||
|
for (SchBaseTask task : tasks) { |
||||
|
TaskUtils.setUpdateByAcs(task); |
||||
|
SendVehicleVo sendVehicleVo = JSONObject.parseObject(task.getRequest_param(), SendVehicleVo.class); |
||||
|
//查询地面点位的载具编码
|
||||
|
// 根据对接位查找对应的载具类型
|
||||
|
SchBasePoint schBasePoint = schBasePointService.selectByRegionCode(sendVehicleVo.getRegion_code(),task.getVehicle_code(),"0"); |
||||
|
if (ObjectUtil.isEmpty(schBasePoint)) { |
||||
|
task.setRemark("未找到所需点位!"); |
||||
|
taskService.updateById(task); |
||||
|
// 消息通知
|
||||
|
noticeService.createNotice("未找到所需点位!", TASK_CONFIG_CODE + task.getTask_code(), |
||||
|
NoticeTypeEnum.WARN.getCode()); |
||||
|
continue; |
||||
|
} |
||||
|
//删除组盘信息
|
||||
|
schBaseVehiclematerialgroupService.remove(new QueryWrapper<SchBaseVehiclematerialgroup>() |
||||
|
.eq("vehicle_code",schBasePoint.getVehicle_code())); |
||||
|
taskService.update(new UpdateWrapper<SchBaseTask>() |
||||
|
.set("task_status",TaskStatus.CREATED.getCode()) |
||||
|
.set("point_code2",schBasePoint.getPoint_code()) |
||||
|
.eq("task_id",task.getTask_id())); |
||||
|
|
||||
|
//更新点位信息
|
||||
|
schBasePoint.setIng_task_code(task.getTask_code()); |
||||
|
schBasePoint.setPoint_status(GoodsEnum.EMPTY_PALLETS.getValue()); |
||||
|
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.update(Wrappers.lambdaUpdate(SchBasePoint.class).eq(SchBasePoint::getPoint_code, startPoint) |
||||
|
.set(SchBasePoint::getIs_lock, false)); |
||||
|
} |
||||
|
String point_code2 = taskObj.getPoint_code2(); |
||||
|
SchBasePoint schBasePoint2 = pointService.selectByPointCode(point_code2); |
||||
|
if (ObjectUtil.isNotEmpty(schBasePoint2)) { |
||||
|
PointUtils.updateByIngTaskCode(schBasePoint2); |
||||
|
pointService.update(Wrappers.lambdaUpdate(SchBasePoint.class).eq(SchBasePoint::getPoint_code, point_code2) |
||||
|
.set(SchBasePoint::getIs_lock, false)); |
||||
|
} |
||||
|
// 任务完成
|
||||
|
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